<!--新闻详情-->
<template>
	<view class="mx-24 my-27">
		<view v-if="loading" class="flex flex-row flex-row-center-center px-50 py-24">
			<tm-icon spin name="tmicon-shuaxin"></tm-icon>
		</view>

		<view v-if="HomeData">
			<view class="text-size-lg text-weight-b">{{ HomeData.title }}</view>
			<view class="pt-23 text-size-n c_qianhui">
				<text class="mr-50">{{ HomeData.created_at }}</text>
				<text>来源：{{ HomeData.author||"平台" }}</text>
			</view>
			<view class="text-size-g py-27">
				<tm-html :content="HomeData.content"></tm-html>
			</view>
		</view>

		<bl-list-layout @restartLoad="geData" :error="error"></bl-list-layout>

	</view>
</template>

<script lang="ts" setup>
import { ref } from "vue"
import { onLoad, onPullDownRefresh } from "@dcloudio/uni-app";
import { apiUr } from "@/libs/api";
import blListLayout from "@/components/bl-list-layout.vue";
const HomeData = ref<any>(null)
const loading = ref(true)
const error = ref(false)
const id = ref("")
onLoad(async (obj: any) => {
	if (obj?.id) {
		id.value = obj?.id;
	}
	geData();
})
onPullDownRefresh(() => {
	if (loading.value) {
		uni.stopPullDownRefresh()
		return;
	}
	geData();
})

async function geData() {
	error.value = false;
	loading.value = true;
	let data = await apiUr.getNewsDetail(id.value).catch((er => {
		error.value = true;
	})).finally(() => {
		uni.stopPullDownRefresh()
		loading.value = false;
	})
	let d = data?.data ?? null;
	if (!d) return;
	HomeData.value = data?.data ?? null;
}



</script>

<style>
page,
body {
	background-color: #F7F7F7;
}
</style>

<style lang="less" scoped></style>